package itdep.common.context;

/**
 * @author Ivan Khalopik
 * @version $Revision: 4 $ $Date: 2010-06-10 13:13:16 +0000 (Thu, 10 Jun 2010) $
 */
public class UserContextImpl<U extends User> implements UserContext<U> {
	private final ThreadLocal<U> userHolder = new ThreadLocal<U>();

	public U getCurrentUser() {
		return userHolder.get();
	}

	public void init(final U user) {
		userHolder.set(user);
	}

	public void clear() {
		userHolder.remove();
	}
}
